package com.vcms.view.simulation.uicomponent.listener;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Title:        VMCS
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      ISS
 * @author Pang Pingli
 * @version 1.0
 */

import java.awt.*;

import com.vcms.controller.maintenance.MaintenanceController;
import com.vcms.view.simulation.uicomponent.dialog.MessageDialog;
import com.vcms.view.simulation.uifactory.EventArgs;
import com.vcms.view.simulation.uifactory.VMCSEventHandler;

public class PriceDisplayListener implements ActionListener, VMCSEventHandler{
	private MaintenanceController mctrl;

	public PriceDisplayListener(MaintenanceController mc) {
		mctrl = mc;
	}

	public void actionPerformed(ActionEvent e) {
		/** @todo: Implement this java.awt.event.ActionListener method */
		TextField txt;

		String sp;
		int ip;
		try {
			txt = (TextField) e.getSource();
			sp = txt.getText();

			ip = Integer.parseInt(sp);
		} catch (NumberFormatException ee) {
			@SuppressWarnings("unused")
			MessageDialog ms = new MessageDialog(mctrl.getMaintenancePanel(),MessageDialog.NUMBER_FORMAT_ERROR);
			return;
		}
		mctrl.setPrice(ip);
	}

	@Override
	public void vmcsActionPerformed(Object eventSource, EventArgs args) {
		ActionEvent event = new ActionEvent(null, 0, null);
		this.actionPerformed(event);
		
	}
}